package com.pluginsacceptor.plugin.formula.MathsTrigo;

/**
 * Concrete Implementation of mathematical functions for the SpreadSheet plugin
 * @author ANAS
 */
public class MathsTrigo implements MathsTrigoAPI{

	/**Somme
	 * @param tab
	 */
	@Override
	public double somme(double[] tab) {
		double somme = 0;
		if (tab.length == 0);
		else 
		{
			somme = tab[0];
		
		for(int i=1; i< tab.length;i++){
			somme = somme + tab[i];			
		}
	}
			return somme;
		
			}

	@Override
	public double produit(double[] tab) {
		double produit = 0;
		if (tab.length == 0);
		else 
		{
			produit = tab[0];
		
		for(int i=1; i< tab.length;i++){
			produit = produit * tab[i];			
		}
		}
			return produit;
	}

	@Override
	public double division(double a, double b) {
		
		if (b !=0)
			return a/b;
		else 
		{ System.out.println("Division par zro !!");
		return (Double) null;
		}
	}

	@Override
	public double soustraction(double a, double b) {
		return (a-b);
		
	}

	@Override
	public int modulo(double a, double b) {
		return (int) (a % b);
	}

	@Override
	public double cos(double a) {
		return (Math.cos(a));
	}

	@Override
	public double sin(double a) {
		return (Math.sin(a));
	}

	@Override
	public double tan(double a) {
		return (Math.tan(a));
	}

	@Override
	public double acos(double a) {
		return (Math.acos(a));
	}

	@Override
	public double asin(double a) {
		return (Math.asin(a));
	}

	@Override
	public double atan(double a) {
		return (Math.atan(a));
	}

	@Override
	public double racine(double a) {
		return (Math.sqrt(a));
	}

	@Override
	public double puissance(double a, double b) {
		return (Math.pow(a, b));
	}

	@Override
	public double exp(double a) {
		return (Math.exp(a));
	}

	@Override
	public double log(double a) {
		return (Math.log(a));
	}
	
	@Override
	public double log10(double a){
		return (Math.log10(a));
	}


	@Override
	public double aleatoire() {
		return (Math.random());
	}
	
	

}
